package main;

//MouseTest2.java
//
// by Dave Small
// v1.0 200611.01: created
// v1.1 200711.26: GUI creation moved to EDT
// v2.0 200903.03: significantly expanded for CIS 4930: Concurrent Programming
// v2.1 200903.04: switched to BorderLayout & added JButton
//
//=============================================================================
// MousePanel
// - clicking on panel selects square region; double clicking deselects
//-----------------------------------------------------------------------------
// illustrates:
// - MouseListeners (click events)
// - MouseMotionListeners (movement events)
// - changing the cursor
// - adding/removing listeners
//
//=============================================================================
// MousePanelFrame
// - displays a MousePanel
//-----------------------------------------------------------------------------
// illustrates:
// - setting content pane contents
// - BorderLayout manager
// - menu building
// - ActionListeners
// - buttons
// - how to run a long task initiated in response to an event on a worker
// thread and when it has completed, use SwingUtilities.invokeLater()
// to update the GUI
//
//=============================================================================
// MouseTest2
// - driver class for the demo
//-----------------------------------------------------------------------------
// illustrates:
// - canonical way to construct GUI: pass task to SwingUtilities.invokeLater()
//
//=============================================================================

import javax.swing.*;

//#############################################################################

public class MouseTest
{
	static private final int WIDTH = 400;
	static private final int HEIGHT = 400;
	
	public static void main( String[] args )
	{
		SwingUtilities.invokeLater( new Runnable() {
			public void run()
			{
				createAndShowGUI();
			}
		});
	}
	
	private static void createAndShowGUI()
	{
		// create the mouse panel
		MousePanel panel = new MousePanel( WIDTH, HEIGHT );
		panel.initialize();
		
		// create the fram to hold it
		MousePanelFrame frame = new MousePanelFrame( panel );
		frame.attachMenuBar();
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
		// layout and display
		frame.pack();	// no need to validate();
		frame.setVisible( true );
	}
}
